#pragma once
#pragma comment(lib, "User32.lib")

#define chDIMOF(Array) (sizeof(Array) / sizeof(Array[0]))

inline void chMB(PCSTR s) 
{
	char szTMP[128];
	::GetModuleFileNameA(NULL, szTMP, chDIMOF(szTMP));
	MessageBoxA(GetActiveWindow(), s, szTMP, MB_OK);
}

inline void chFAIL(PSTR szMsg) 
{
	chMB(szMsg);
	DebugBreak();
}

// Put up an assertion failure message box.
inline void chASSERTFAIL(LPCSTR file, int line, PCSTR expr) 
{
	char sz[128];
	wsprintfA(sz, "File %s, line %d : %s", file, line, expr);
	chFAIL(sz);
}

#ifdef _DEBUG

#define chASSERT(x) if (!(x)) chASSERTFAIL(__FILE__, __LINE__, #x)

#else

#define chASSERT(x)

#endif